
#include "CGameApplication.h"
#include "CKeyboardHandler.h"

void CKeyboardHandler::inputLogic()
{
	Uint8 *keystates = SDL_GetKeyState( NULL );

	if ( ( keystates[SDLK_UP] || keystates[SDLK_DOWN] || keystates[SDLK_LEFT] || keystates[SDLK_RIGHT] ))
	{
		if (keystates[SDLK_UP])
		{
			CGameApplication::getInstance()->getGameApp()->getPlayer()->movePlayer(SDLK_UP);
		}

		if (keystates[SDLK_DOWN])
		{
			CGameApplication::getInstance()->getGameApp()->getPlayer()->movePlayer(SDLK_DOWN);
		}
	
		if (keystates[SDLK_LEFT])
		{
			CGameApplication::getInstance()->getGameApp()->getPlayer()->movePlayer(SDLK_LEFT);
		}

		if (keystates[SDLK_RIGHT])
		{
			CGameApplication::getInstance()->getGameApp()->getPlayer()->movePlayer(SDLK_RIGHT);
		}
	}
	
	else
	{
		CGameApplication::getInstance()->getGameApp()->getPlayer()->movePlayer(CGameApplication::getInstance()->getGameApp()->getPlayer()->getLastMakeMovement());
	}


}